import request from '@/utils/http.js'

// 获取仪表盘统计数据
export const getDashboardStats = () => {
    return request.get('/admin/dashboard/stats')
}

// 获取近七天订单统计
export const getRecentOrdersStats = () => {
    return request.get('/admin/dashboard/orders/recent')
}

// 获取近三个月订单统计
export const getRecentThreeMonthsOrdersStats = () => {
    return request.get('/admin/dashboard/orders/recent-three-months')
}

// 获取近七天营收统计
export const getRecentRevenueStats = () => {
    return request.get('/admin/dashboard/revenue/recent')
}

// 获取商品统计
export const getGoodsStats = () => {
    return request.get('/admin/dashboard/goods/stats')
}

// 分页获取用户列表，支持搜索
export const getUsers = (params) => {
    return request.get('/admin/users', { params })
}

// 更新用户信息
export const updateUser = (uid, userData) => {
    return request.put(`/admin/users/${uid}`, userData)
}

// 删除用户
export const deleteUser = (uid) => {
    return request.delete(`/admin/users/${uid}`)
}

// 获取所有融资申请
export const getAllFinanceApplications = () => {
    return request.get('/admin/finance/applications')
}

// 通过申请
export const approveApplication = (financeId, opinion) => {
    return request.post(`/admin/finance/approve/${financeId}`, { opinion })
}

// 拒绝申请
export const rejectApplication = (financeId, opinion) => {
    return request.post(`/admin/finance/reject/${financeId}`, { opinion })
}

// 放款
export const disburseApplication = (financeId, opinion) => {
    return request.post(`/admin/finance/disburse/${financeId}`, { opinion })
}

// 还款
export const repayApplication = (financeId, opinion) => {
    return request.post(`/admin/finance/repay/${financeId}`, { opinion })
}